/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.session;

import com.aptech.entity.Member1;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Tuan Nguyen
 */
@Stateless
public class Member1Facade extends AbstractFacade<Member1> implements Member1FacadeLocal {
    @PersistenceContext(unitName = "mysweethome.com-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public Member1Facade() {
        super(Member1.class);
    }

    @Override
    public List<Member1> findByEmail(String email) {
        Query q=em.createNativeQuery("Select * from Member where Email like ?value AND IsActive='True'",Member1.class);
        q.setParameter("value", email);
        return q.getResultList();
    }

    @Override
    public java.util.List<Member1> SearchMember(String field, Object value) {
        Query q=em.createNativeQuery("SELECT * FROM Member AS e WHERE "+field+" like ?value", Member1.class);
        q.setParameter("value", value);
        return q.getResultList();
    }
  
}
